<template>
    <div>
         <div class="indexke" id='ke'>
        <!-- 头部 -->
       <div class="head"> 
           <i class="iconfont icon-fanhui" @click="$router.go(-1)"></i>
           {{title}}
            <i class="iconfont icon-fenxiang isshow" v-show="!flag" ></i>
            <span v-show="flag" class="isshow">分享</span>
       </div>    
                   <!-- title -->
            <div class="title">
                <p style="font-size:20px">{{info.title}}</p>
                <p class="zi">{{info.price}}</p>
                <p>共{{info.sale_type}}课时|{{info.browse_num}}人已报名</p>
                <p>开课时间{{info.end_play_date|timers}}--{{info.start_play_date|timers}}</p>
                 <p class="cang" @click="shous" v-if="!flags"><van-icon name="star-o" /></p>
                  <p class="cang" @click="xiao" v-if="flags"><van-icon name="star-o" color='orange'/></p>
            </div>
            <!-- 教训团队 -->
            <div class="tuan">
                <p style="font-size:20px">教学团队</p>
                <ul>
                    <li v-for="(item,index) in teacher" :key="index">
                        <p><img :src="item.avatar" alt=""></p>
                        <p>{{item.teacher_name}}</p>
                    </li>
                </ul>
            </div>
            <!-- 课程介绍 -->
            <div class="jie">
                <div style="font-size:20px" >课程介绍
                      <p v-html="info.course_details">
                          </p></div>
            </div>
            <!--大纲 -->
               <div class="jie">
                <p style="font-size:20px">课程大纲</p>
                   {{info.title}}
                   <p >{{info.end_play_date|timers}}</p>
            </div>
               <div class="jie">
                <p style="font-size:20px">课程评论</p>
                <van-empty  />
            </div>
            <!-- 报名 -->
            <van-button  size="large">立即报名</van-button>
            <div class="ding"></div>
            <div class="ding"></div>
            <div class="ding"></div>
            <div class="ding"></div>
            <div class="ding"></div>
            <div class="ding"></div>
    </div>
    </div>
</template>
<script>
import { Toast } from 'vant';
import {ClassDetail,shou,shx} from '../../Request/http'
export default {
     name: 'EverydayCoursedet',
    data() {
        return {
             title: "课程详情",
      info: [],
      teacher: [],
      flag: false,
      flags:false,
      id:0,
    collect_id:0
        };
    },
    mounted() {
        var ke = document.getElementById("ke");
    console.log(ke);
    ke = addEventListener("scroll", e => {
        console.log(e);
       if(document.documentElement.scrollTop>50){
           console.log(document.documentElement.scrollTop)
           this.title='课程介绍 课程大纲 课程评论'
           this.flag=true
       }else{
           this.title= "课程详情"
           this.flag=false
       }
    });
    var id = this.$route.query.id;
    this.id=id
    ClassDetail(this.id).then(res => {
      console.log(res);
      this.info = res.info;
       this.collect_id=res.info.collect_id
      this.teacher = res.teachers;
    });
    },
    methods: {
        shous(){
          this.flags=!this.flags
           if(this.flags){
                Toast({
  message: '收藏成功',
  position: 'bottom',
});
              
            }else{
                 Toast({
  message: '取消收藏',
  position: 'bottom',
});       
            }
          shou({course_basis_id:this.id,type:1}).then((res)=>{
            console.log(res)
              ClassDetail(this.id).then(res => {
      console.log(res);
      this.info = res.info;
      this.collect_id=res.info.collect_id
      this.teacher = res.teachers;
    });
          })
        },
        xiao(){
          console.log('ewrw')
            this.flags=!this.flags
             if(this.flags){
                Toast({
  message: '收藏成功',
  position: 'bottom',
});
              
            }else{
                 Toast({
  message: '取消收藏',
  position: 'bottom',
});
                 
            }
         shx(this.collect_id).then((res)=>{
           console.log(res)
           console.log(this.collect_id)
             ClassDetail(this.id).then(res => {
      console.log(res);
      this.info = res.info;
       this.collect_id=res.info.collect_id
      this.teacher = res.teachers;
    });
         })
        }
    },
};
</script>
<style lang="scss" scoped>
.indexke {
  width: 100%;
  height: 100%;
  background: rgb(230, 227, 227);
  .head {
    width: 100%;
    line-height: 60px;
    text-align: center;
    font-size: 18px;
    position: fixed;
    top: 0;
    left: 0;
    // position: relative;
    background: #fff;
    .icon-fanhui {
      font-size: 20px;
      position: absolute;
      top: 0;
      left: 20px;
    }
    .isshow {
      font-size: 20px;
      position: absolute;
      top: 0;
      right: 20px;
    }
  }
  .title {
    margin-top: 50px;
    width: 100%;
    padding: 20px;
    background: #fff;
    box-sizing: border-box;
    line-height: 30px;
    font-size: 14px;
    position: relative;
    .zi {
      color: rgb(233, 187, 103);
      font-size: 20px;
    }
        .cang{
      position: absolute;
      top:20px;
      right:20px;
      z-index:99;
    }
  }
  .tuan {
    width: 100%;
    padding: 20px;
    margin-top: 10px;
    box-sizing: border-box;
    background: red;
    box-sizing: border-box;
    margin-bottom: 20px;
    background: #fff;
    ul {
      margin-top: 20px;
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      li {
        text-align: center;
        line-height: 30px;
        img {
          width: 50px;
          height: 50px;
          border-radius: 50%;
        }
      }
    }
  }
  .jie {
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    background: #ffff;
    margin-bottom: 20px;
    margin-top: 20px;
    // height: 80px;
    font-size: 18px;
    line-height: 30px;
    box-sizing: border-box;
  }
  .van-button {
    width: 100%;
    box-sizing: border-box;
    position: fixed;
    bottom: 0;
    left: 0;
    background: orange;
    color: #ffff;
  }
  .ding {
    width: 100%;
    height: 300px;
    background: rgb(230, 227, 227);
  }
}
</style>